#ifndef __BLUETOOTH_H__
#define __BLUETOOTH_H__

#define BLUE_UART_RCC           RCC_APB1Periph_USART2
#define BLUE_GPIO_RCC           (RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO)
#define BLUE_UART               USART2
#define BLUE_UART_IRQ           USART2_IRQChannel
#define BLUE_GPIO               GPIOA
#define BLUE_RX_PIN             GPIO_Pin_2
#define BLUE_TX_PIN             GPIO_Pin_3

#define bluetooth_isr_handler   USART2_IRQHandler


struct xbluetooth {
    void *data;
    event_callback_t callback;
};

#ifdef __cplusplus
extern "C" {
#endif

extern void bluetooth_open( struct xbluetooth * blue );
extern unsigned long bluetooth_read(unsigned char *buffer);
extern unsigned long bluetooth_write(unsigned char *buffer);
extern void bluetooth_register_callback(event_callback_t callback);
extern void bluetooth_set_baudrate(unsigned long baudrate);
extern void bluetooth_close( struct xbluetooth * blue );

#ifdef __cplusplus
}
#endif
#endif